﻿using System;
using System.Collections.Generic;
using System.Text;
using Axis.BusinessObject.News;
using Axis.BusinessObject.Core;
using Axis.Dao.SQL;
using Axis.Dao.Base;
using FWS.Framework.Log;

namespace Axis.Dao.News
{
    public class CNewsDao : CDaoBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CNews> GetNews(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CNews> list = CallFunctionWithList<CNews>(CSystemFunction.GetNews, pInputValue, ref output);
                LastOutputValue = output;
                
                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE" Title="" Summary="" Content="" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionNews(string pInputValue)
        {
            try{
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionNews, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CTag> GetTags(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CTag> list = CallFunctionWithList<CTag>(CSystemFunction.GetTags, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetTags", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" SecrectToken="" ID="1" IDs="1,2,3" Text="" Action="INSERT|UPDATE|DELETE|DELETEMULTI"/>
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionTags(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionTags, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionTags", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" Tags="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CContent> GetContent(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CContent> list = CallFunctionWithList<CContent>(CSystemFunction.GetContent, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }
    }
}
